<?php
$conn = mysql_connect("localhost", "root", "643313") OR DIE (mysql_error());
mysql_select_db ("test") OR DIE ("Unable to select db".mysql_error());
$sql = "SELECT * FROM images";
$result = mysql_query($sql, $conn) or die("Invalid query: " . mysql_error());

while ($row = mysql_fetch_assoc($result)) {
	$type = $row['type'];
	header( "Content-type: image/$type" );
	echo $row['image'];
}
?>